Skip to content

fix(ocpp): keep the AuthorizationKey out of GetConfiguration and logs (#203) - #206

Merged
basmeerman merged 2 commits into
masterfrom
fix/ocpp-authkey-redact
Oct 5, 2026
Merged

basmeerman merged 2 commits into
masterfrom
fix/ocpp-authkey-redact

Conversation

@basmeerman

@basmeerman basmeerman commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Refs #203. Stacked on #205 (which is stacked on #204); merge in order #204 → #205 → this, retargeting each to master.

Problem

MicroOcppMongoose declares AuthorizationKey readable, so GetConfiguration returned the value to the backend, and debug builds printed the reply ([MO] Send: ...) on the unauthenticated telnet console. OCPP 1.6 treats the key as write-only.

Deviation from the issue's acceptance criteria

The issue asked for a declare-flag patch in the vendored library plus a CI guard. MicroOcpp/MicroOcppMongoose are pinned lib_deps, not vendored, and MicroOcpp's accessible flag works per configuration file: it would also hide Cst_BackendUrl/Cst_ChargeBoxId and block key rotation via ChangeConfiguration. So this is a firmware-side fix instead.

Fix

  • GetConfiguration: MicroOcpp's handler is replaced (registerOperation replaces by name) with a subclass that drops the optional value of secret keys (ocpp_config_key_is_secret()). The key is still listed and can still be changed by the backend.
  • Console: ocpp_console_out() runs every MicroOcpp line through ocpp_redact_auth_key(): GetConfiguration replies, ChangeConfiguration requests in either field order, lines cut off inside the value by the 256-byte console buffer, and the MicroOcppMongoose auth Token=<id>:<key> debug line. The value becomes ***; the line never grows.

Verification

  • Native tests: 65/65 suites (new test_ocpp_secrets.c, 11 tests, REQ-OCPP-130/131/132)
  • ASan/UBSan
  • cppcheck (CI file list + net_watchdog.c)
  • pio run -e release: flash 87.7%, RAM 24.0%; debug 92.3% / 24.2%
  • Wrapper checked against the pinned MicroOcpp (942fb88) with its native Catch2 suite: without it the key is returned, with it it is not, for both an all-keys and an explicit-key request
  • Hardware: not tested (no spare unit)

Also in this PR

  • POST /settings no longer echoes a newly set ocpp_auth_key; it answers ocpp_auth_key_set: true/false, like the MQTT password (SECURITY C-2). The Web UI does not read the field. ocpp_auth_key_is_set() backs both GET and POST (REQ-OCPP-132). docs/security.md updated.

🤖 Generated with Claude Code

basmeerman and others added 2 commits October 5, 2026 22:44
MicroOcppMongoose declares AuthorizationKey as a readable configuration
key, so GetConfiguration returned its value to the backend, and debug
builds printed that reply on the unauthenticated telnet console. OCPP
1.6 makes the key write-only.

MicroOcpp is a pinned lib_dep, not vendored, and its accessibility flag
works per configuration file (it would also hide BackendUrl/ChargeBoxId
and block key rotation via ChangeConfiguration), so the fix is in the
firmware:

- Replace MicroOcpp's GetConfiguration handler with a subclass that
  drops the optional "value" of secret keys. The key is still listed and
  can still be changed by the backend.
- Redact the key in every MicroOcpp console line: GetConfiguration
  replies, ChangeConfiguration requests in either field order, lines cut
  off inside the value by the 256-byte console buffer, and the
  MicroOcppMongoose "auth Token=" debug line.

Decisions live in ocpp_logic.c with native tests (REQ-OCPP-130/131).
The wrapper was also checked against the pinned MicroOcpp with its
native Catch2 suite: without it the key leaks, with it it does not, for
both an all-keys and an explicit-key request.

Refs #203

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Setting ocpp_auth_key returned the stored key in the response. The
caller just sent it, but SECURITY C-2 says the key is never returned to
an HTTP client; replies and proxies or browser tools can keep it. Answer
ocpp_auth_key_set: true/false instead, as POST already does for the MQTT
password. The Web UI does not read the field.

ocpp_auth_key_is_set() in ocpp_logic.c now backs both GET and POST
(REQ-OCPP-132). docs/security.md describes the POST reply and the
GetConfiguration/console redaction from the previous commit.

Refs #203

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@basmeerman
basmeerman changed the base branch from fix/ocpp-queue-reinit to master October 5, 2026 21:30
@basmeerman basmeerman closed this Oct 5, 2026
@basmeerman basmeerman reopened this Oct 5, 2026
@basmeerman
basmeerman merged commit 0285138 into master Oct 5, 2026
21 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant